package com.zw.yzk.kabu.data.repository;

import com.zw.yzk.kabu.data.network.ServiceGenerator;
import com.zw.yzk.kabu.data.network.entity.CheckQrEntity;
import com.zw.yzk.kabu.data.network.service.CheckQrCodeService;
import com.zw.yzk.kabu.data.network.task.CheckQrTask;
import com.zw.yzk.kabu.data.network.task.Task;

import javax.inject.Inject;

import rx.Observable;
import rx.functions.Func1;

/**
 * Created by zhanwei on 2016/12/24.
 */

public class CheckQrCodeRepository extends CommonRepository {

    @Inject
    public CheckQrCodeRepository() {

    }

    @Override
    protected Observable connectServer(Task task) {
        CheckQrCodeService loginService = ServiceGenerator.createService(CheckQrCodeService.class);
        CheckQrTask collectGoodsTask = (CheckQrTask) task;

        return loginService.checkQrCode(collectGoodsTask.serialCode, collectGoodsTask.checkCode, collectGoodsTask.userId, collectGoodsTask.accessToken);
    }

    @Override
    protected Func1<CheckQrEntity, Observable> getServerData() {
        return new Func1<CheckQrEntity, Observable>() {
            @Override
            public Observable call(CheckQrEntity entity) {
                return Observable.just(entity);
            }
        };
    }

}
